package com.cy.controller;

import com.cy.common.pojo.CheckBox;
import com.cy.common.pojo.JsonResult;
import com.cy.common.untils.PageUtil;
import com.cy.pojo.SysRole;
import com.cy.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/role")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;

    @GetMapping("/selectSysRole/{roleName}")
    public JsonResult selectSysRole(@PathVariable String roleName){
        return new JsonResult(PageUtil.startPage()
                .doSelectPageInfo(()->sysRoleService.selectSysRole(roleName)));
    }

    @DeleteMapping("/deleteSysRole/{id}")
    public JsonResult deleteSysRole(@PathVariable Integer id){
        return new JsonResult(sysRoleService.deleteSysRole(id));
    }

    @PutMapping("/updateSysRole")
    public JsonResult updateSysRole(@RequestBody SysRole sysRole){
        return new JsonResult(sysRoleService.updateSysRole(sysRole));
    }

    @PutMapping("/insertSysRole")
    public JsonResult insertSysRole(@RequestBody SysRole sysRole){
        return new JsonResult(sysRoleService.insertSysRole(sysRole));
    }

    @GetMapping("/findByRoleId/{id}")
    public JsonResult findByRoleId(@PathVariable Integer id){
        return new JsonResult(sysRoleService.findByRoleId(id));
    }

    @GetMapping("/selectCheckRoles")
    public JsonResult selectCheckRoles(){
        return new JsonResult(sysRoleService.selectCheckRoles());
    }
}
